/*
 * @Author: 飞越疯人院 353362604@qq.com
 * @Date: 2022-10-14 09:00:55
 * @LastEditors: 飞越疯人院 353362604@qq.com
 * @LastEditTime: 2022-12-16 08:32:38
 * @FilePath: \adminstration\src\Common\Modal\TwoModalList\EnterpriseFiles.jsx
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { API_LIST } from '../../Api/Api'
import { BuiltInData } from '../config'
import { TwoAddBtn, ThrDeleteBtn, SeeEnclosure } from '../options'

export const SecurityProblem = async ({ upDataEvent, data, Permission }) => {
    let dataList = {
        type: '安全巡检问题详情',
        hideInSearch: true,
        pageSize: 10,
        params: { SecurityUuid: data.uuid },
        classification: 'TableModal',
        get: API_LIST()['getSecurityAttachment'],
        options: [
            data.auditStatus === -1 &&
                Permission.findIndex(v => v.uuid === '1956e28f-6152-45b9-81cc-8fc0868796da') !== -1 && (
                    <TwoAddBtn
                        upDataEvent={upDataEvent}
                        title="添加附件"
                        ThrKey="ThrModal"
                        value="SecurityProblem"
                        data={data}
                    />
                ),
        ],
        columns: [
            {
                dataIndex: 'originalName',
                title: '文件标题',
                valueType: 'input',
                hideInAdded: true,
                hideInModify: true,
            },
            {
                dataIndex: 'fileType',
                title: '文件类型',
                valueType: 'select',
                valueEnum: BuiltInData.FileType,
                rules: true,
                width: 350,
                className: 'RemarkForm',
            },
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 300,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    const { uuid, fileUrl } = record
                    return [
                        fileUrl && (
                            <SeeEnclosure
                                key="seeFile"
                                title="查看附件"
                                data={{
                                    className: 'Admin',
                                    url: fileUrl,
                                }}
                            />
                        ),
                        data.auditStatus === -1 &&
                            Permission.findIndex(v => v.uuid === 'a9973d99-d9c9-44d2-9345-e00fbc26a4d4') !== -1 && (
                                <ThrDeleteBtn
                                    key="delete"
                                    additional={[uuid]}
                                    record={data.uuid}
                                    upDataEvent={upDataEvent}
                                    data={{ key: 'delete', url: 'delSecurityAttachment', title: '删除附件' }}
                                />
                            ),
                    ]
                },
            },
        ],
    }

    return dataList
}
